frequencyTableIntervalsDialog <-
function(){
    require(TeachingExtras)
    initializeDialog(title = gettext("Frequency table (grouped numerical data)",domain="R-RcmdrPlugin.TeachingExtras"))
    xBox <- variableListBox(top, Numeric(), title = gettext("Variable (pick one)",domain="R-RcmdrPlugin.TeachingExtras"))
    optionsFrame <- tkframe(top)
    radioButtons(optionsFrame, name="intervals", buttons = c("automatic", 
        "number", "limits"), labels = gettext(c("Automatic", "Num intervals", "Intervals limits"),domain="R-RcmdrPlugin.TeachingExtras"), 
        title = gettext("Clases definition",domain="R-RcmdrPlugin.TeachingExtras"))
    numIntervals <- tclVar(gettextRcmdr(""))
    entryIntervals <- tkentry(optionsFrame, width = "10", textvariable = numIntervals)
    onOK <- function() {
        x <- getSelection(xBox)
        .activeDataSet <- ActiveDataSet()
        if (length(x) == 0) {
            errorCondition(recall = frequencyTableDialog, message = gettext("You must select a variable.",domain="R-RcmdrPlugin.TeachingExtras"))
            return()
        }
        intervalsValue = tclvalue(intervalsVariable)
        if (intervalsValue == "number") {
            command <- paste("frequencyTableIntervals(", .activeDataSet, "$", x, ", breaks=", as.character(tclvalue(numIntervals)), ")", sep = "")
        }
        else if (intervalsValue == "limits") {
            command <- paste("frequencyTableIntervals(", .activeDataSet, "$", x, ", breaks=c(", as.character(tclvalue(numIntervals)), "))", sep = "")
        }
	else 
            command <- paste("frequencyTableIntervals(", .activeDataSet, "$", x, ")", sep = "")
        
        doItAndPrint(command)
        closeDialog()
        tkfocus(CommanderWindow())
    }
    OKCancelHelp(helpSubject = "frequencyTableIntervals")
    tkgrid(getFrame(xBox), sticky = "nw")
    tkgrid(optionsFrame, sticky = "w")
    tkgrid(buttonsFrame, sticky = "w")
    tkgrid(intervalsFrame, tklabel(optionsFrame, text = gettext("Intervals: ",domain="R-RcmdrPlugin.TeachingExtras")), entryIntervals, sticky = "e")
    dialogSuffix(rows = 4, columns = 2)
}

